//
//  AllButtonCollectionViewCell.m
//  HappinessTrip
//
//  Created by dllo on 15/10/9.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "AllButtonCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation AllButtonCollectionViewCell
-(void)dealloc
{
    [_backImageView release];
    [_pictureImageView release];
    [_titleLabel release];
    [_userImageView release];
    [_userLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    _backImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_backImageView];
    [_backImageView release];
    _pictureImageView = [[UIImageView alloc]init];
    [_backImageView addSubview:_pictureImageView];
    [_pictureImageView release];
    _titleLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_titleLabel];
    [_titleLabel release];
    _userImageView = [[UIImageView alloc]init];
    [_backImageView addSubview:_userImageView];
    [_userImageView release];
    _userLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_userLabel];
    [_userLabel release];
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _backImageView.frame = self.contentView.frame;
    _pictureImageView.frame = CGRectMake(0, 0, _backImageView.frame.size.width, 120 * H);
    _titleLabel.frame = CGRectMake(_pictureImageView.frame.origin.x + 10 * W, _pictureImageView.frame.origin.y + _pictureImageView.frame.size.height + 10 * H, _pictureImageView.frame.size.width - 20 * W, 40 * H);
    _userImageView.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 10 * H, 30 * W, 30 * W);
    _userLabel.frame = CGRectMake(_userImageView.frame.origin.x + _userImageView.frame.size.width + 10 * W, _userImageView.frame.origin.y + 5 * H, _titleLabel.frame.size.width - _userImageView.frame.size.width - 10 * W, 20 * H);

}
-(void)setAllButton:(AllButton *)allButton
{
    if (_allButton != allButton) {
        [_allButton release];
        _allButton = [allButton retain];
    }
    _backImageView.backgroundColor = [UIColor colorWithRed:0.56 green:0.53 blue:0.93 alpha:1];
    _backImageView.layer.cornerRadius = 10;
    _backImageView.layer.masksToBounds = YES;
    [_pictureImageView sd_setImageWithURL:[NSURL URLWithString:_allButton.index_cover] placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _titleLabel.text = _allButton.index_title;
    _titleLabel.font = [UIFont systemFontOfSize:13];
    _titleLabel.numberOfLines = 0;
    [_userImageView sd_setImageWithURL:[NSURL URLWithString:[_allButton.user objectForKey:@"avatar_m"]] placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _userImageView.layer.cornerRadius = _userImageView.frame.size.width / 2;
    _userImageView.layer.masksToBounds = YES;
    _userLabel.text = [_allButton.user objectForKey:@"name"];
    _userLabel.font = [UIFont systemFontOfSize:13];
    _titleLabel.textColor = [UIColor whiteColor];
    _userLabel.textColor = [UIColor whiteColor];
    
}

















@end
